import {WidgetType} from "../index";
import {customAlphabet} from "nanoid";

const nextId = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')

export interface IWidgetProps {
  widgetId?: string,
  widgetLabel?: string,
  widgetType?: WidgetType,
}

export default class WidgetProps implements IWidgetProps {

  public widgetId = nextId();
  public widgetLabel = "NONE";
  public widgetType = "NONE" as WidgetType;

  constructor(props?: IWidgetProps) {
    if (props) {
      this.widgetType = props.widgetType || this.widgetType;
      this.widgetLabel = props.widgetLabel || this.widgetLabel;
      this.widgetId = props.widgetId || (this.widgetType+"_"+this.widgetId);
    }
  }

}